package org.asiainfo.common.translation.core.impl;

import lombok.AllArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference;
import org.asiainfo.common.translation.annotation.TranslationType;
import org.asiainfo.common.translation.constant.TransConstant;
import org.asiainfo.common.translation.core.TranslationInterface;
import org.asiainfo.system.api.RemoteDeptService;

/**
 * 部门翻译实现
 */
@AllArgsConstructor
@TranslationType(type = TransConstant.DEPT_ID_TO_NAME)
public class DeptNameTranslationImpl implements TranslationInterface<String> {

    @DubboReference
    private RemoteDeptService remoteDeptService;

    /**
     * 通过部门ID查询部门名称
     *
     * @param key   需要被翻译的键(不为空)
     * @param other 其他参数
     * @return 翻译后的值
     */
    @Override
    public String translation(Object key, String other) {
        return remoteDeptService.selectDeptNameByIds(key.toString());
    }
}
